home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / mini / Battery-Powered < prev    next >
Text File  |  1997-12-28  |  32KB  |  729 lines

  1.   Battery Powered Linux Mini-HOWTO
  2.   Hanno Mueller, hanno@lava.de http://www.lava.de/~hanno/
  3.   Dec 21, 1997
  4.  
  5.   This document describes how to reduce a Linux system's power consump¡
  6.   tion by tweaking some of its configuration settings. This will be
  7.   helpful for everyone who runs Linux on a portable computer system.
  8.   There is also some general information about how to take care of your
  9.   battery. If you are using Linux on a desktop system, you probably
  10.   don't need to read all this.
  11.  
  12.   1.  Introduction
  13.  
  14.   ``Ages 6 and up. Batteries included.''
  15.  
  16.   1.1.  Before you ask
  17.  
  18.   This document does not describe how to install Linux on laptops, but
  19.   how to optimize a ready-configured Linux for use on laptops. Please
  20.   read the Installation-HOWTO or your distributor's handbook for help
  21.   with installing Linux.
  22.  
  23.   This document does not describe how to use an uninterruptable power
  24.   supply and the powerd daemon, either (even though a ups is a big
  25.   battery). Read the UPS-HOWTO for details about that subject.
  26.  
  27.   1.2.  What this document is about
  28.  
  29.   More and more people own portable computers these days and in turn,
  30.   more and more people install Linux on such machines.
  31.  
  32.   Installing and using Linux on a laptop is usually no problem at all,
  33.   so go ahead and give it a try. Unlike some other operating systems,
  34.   Linux still supports and runs well on even very old hardware, so you
  35.   might give your outdated portable a new purpose in life by installing
  36.   Linux on it.
  37.  
  38.   If you need help with installing Linux on a laptop or if you have
  39.   questions about laptop hardware, you can check the excellent Linux
  40.   Laptop webpage at http://www.cs.utexas.edu/users/kharker/linux-laptop/
  41.   where you will find a lot of useful information and detailed help. The
  42.   Linux Laptop page describes hardware configuration for specific laptop
  43.   models and chipsets.
  44.  
  45.   This HOWTO however will focus on the one problem that is common to all
  46.   portable systems: Power consumption.
  47.  
  48.   Yet, I have not found a Linux distribution that comes with a
  49.   configuration optimized for laptops. Since I could not find this kind
  50.   of information anywhere else, I have started to collect a few simple
  51.   but effective tricks that will help you save battery power and in turn
  52.   increase your system's uptime while running on battery.
  53.  
  54.   (Sidenote. I received a complaint by a reader that these tips were not
  55.   very effective with his laptop. So does all this really work? Yes, but
  56.   don't expect miracles. I was able to increase my laptop's battery time
  57.   from 90 minutes to more than 120 minutes.)
  58.  
  59.   1.3.  Roadmap
  60.  
  61.   If you are a laptop pro, you can probably skip the ``General
  62.   Information'' section. If you are a Linux pro, what you really want to
  63.   know can be found in the ``Changing some general system settings''
  64.   section. If you are a Linux distributor, please read ``A message to
  65.   Linux distributors''.
  66.  
  67.   1.4.  Feedback
  68.  
  69.   Your feedback is welcome. Please send comments to hanno@lava.de. Did
  70.   it work on your system? Do you have new tips? Are there any outdated
  71.   links or addresses in this text?
  72.  
  73.   I am sorry, but I will not be able to help you with questions about
  74.   specific laptop models. I don't claim to be a laptop guru, I just
  75.   happen to own one laptop myself and I simply want to share the
  76.   information I collected. Please check the Linux Laptop webpage first,
  77.   probably someone else has already written a page dedicated to your
  78.   model. Ask your manufacturer's technical support. Or go the the laptop
  79.   newsgroup comp.sys.laptops and ask there.
  80.  
  81.   1.5.  Disclaimer
  82.  
  83.   All methods described here were tested by me and worked fine on my
  84.   laptop, unless noted otherwise. However, I cannot guarantee that any
  85.   of this won't crash or seriously damage your system. Life is
  86.   dangerous, so keep backup copies of your important files before
  87.   playing with your Linux configuration. If things go wrong, I do not
  88.   take any responsibility for your data loss. In other words: Don't sue
  89.   me. Thank you.
  90.  
  91.   1.6.  Copyright
  92.  
  93.   This document shall be distributed under the standard HOWTO-copyright
  94.   notice, found in the HOWTO folder at
  95.   http://sunsite.unc.edu/mdw/linux.html.
  96.  
  97.   2.  General information
  98.  
  99.   This section describes a few technical things about laptop batteries
  100.   and some general power saving tips. This information is not Linux-
  101.   specific and if you are experienced with laptops, you might already
  102.   know all this.
  103.  
  104.   2.1.  Be kind to your battery
  105.  
  106.   (Please note the ``credits'' for this section.)
  107.  
  108.   There are currently three types of batteries commonly used for
  109.   portable computers.
  110.  
  111.   ╖  NiCd batteries were the standard technology for years, but today
  112.      they are out of date and new laptops don't use them anymore. They
  113.      are heavy and very prone to the ``memory effect''. When recharging
  114.      a NiCd battery that has not been fully discharged, it ``remembers''
  115.      the old charge and continues there the next time you use it.
  116.  
  117.      The memory effect is caused by crystallization of the battery's
  118.      substances and can permanently reduce your battery's lifetime, even
  119.      make it useless. To avoid it, you should completely discharge the
  120.      battery and then fully recharge it again at least once every few
  121.      weeks.
  122.  
  123.      (A sidenote about the memory effect. James Youngman knows of a
  124.      rather drastic method to - uhm - ``repair'' batteries: ``If your
  125.      NiCd battery is suffering from the memory effect, remove it from
  126.      your computer, hold it about 30cm above a desk or the floor, and
  127.      drop it (make sure it lands flat).'' He says that this will break
  128.      the whiskers that have formed in the battery and that are the cause
  129.      of the memory effect if your battery is already affected by it. ``I
  130.      don't know if this works for non-NiCd batteries or not.'')
  131.  
  132.      Cadmium is a very hazardous poison, but if returned to your dealer,
  133.      the material can almost be fully recycled.
  134.  
  135.      Just in case you might be interested, here are some specs for NiCd:
  136.  
  137.        Cell voltage: 1,2 V
  138.        Energy / mass: 40 Wh/kg
  139.        Energy / volume: 100 Wh/l
  140.        max. Energy: 20 Wh
  141.        Charge temp.: 10 to 35 C (50 to 95 F)
  142.        Discharge temp.: -20 to 50 C (-5 to 120 F)
  143.        Storage temp.: 0 to 45 C (30 to 115 F)
  144.  
  145.   ╖  NiMh batteries are the current standard used in most low price
  146.      laptops to date. They can be made smaller and are less affected by
  147.      the memory effect than NiCd.
  148.  
  149.      However, they have problems at very high or low room temperatures.
  150.      And even though they use less hazardous and non-poisonous
  151.      substances, they cannot be fully recycled yet (but this will
  152.      probably change in the future).
  153.  
  154.      NiMh specs:
  155.  
  156.        Cell voltage: 1,2 V
  157.        Energy / mass: 55 Wh/kg
  158.        Energy / volume: 160 Wh/l
  159.        max. Energy: 35 Wh
  160.        Charge temp.: 10 to 35 C (50 to 95 F)
  161.        Discharge temp.: 0 to 45 C (30 to 115 F)
  162.        Storage temp.: 0 to 30 C (30 to 85 F)
  163.  
  164.   ╖  The new high performance batteries use LiIon technology. In theory,
  165.      there is no memory effect at all with these batteries, but on
  166.      occasion, they seem to have similar problems. Their substances are
  167.      non-hazardous to the enviroment, but they should be returned for
  168.      recycling as well.
  169.  
  170.      LiIon specs:
  171.  
  172.        Cell voltage: 3,6 V
  173.        Energy / mass: 100 Wh/kg
  174.        Energy / volume: 230 Wh/l
  175.        max. Energy: 60 Wh
  176.        Charge temp.: 0 to 45 C (30 to 115 F)
  177.        Discharge temp.: -20 to 60 C (-5 to 140 F)
  178.        Storage temp.: -20 to 60 C (-5 to 140 F)
  179.  
  180.   Even if the battery case looks the same, you cannot just upgrade to
  181.   another battery technology. The recharging process is different for
  182.   the kind of battery you use.
  183.  
  184.   Some manufacturers integrate the recharging circuit inside the
  185.   laptop's external ac adapter, so you might just get away with buying a
  186.   new power supply to upgrade. A good indication for an external
  187.   recharging unit is when your ac adapter uses a proprietary connector
  188.   with a lot of power lines.
  189.  
  190.   Other manufacturers put the recharging unit inside the laptop case
  191.   where users cannot simply replace it with a newer technology. If your
  192.   ac adapter only uses two power lines to connect to the computer (just
  193.   like mine), the recharging unit is probably inside the laptop.
  194.  
  195.   When in doubt, ask your manufacturer if your laptop supports a more
  196.   modern battery.
  197.  
  198.   A battery that is not used for a long time will slowly discharge
  199.   itself. And even with greatest care, a battery needs to be replaced
  200.   after 500 to 1000 recharges. But still it is not recommended to run a
  201.   laptop without the battery while on ac power - the battery often
  202.   serves as a big capacitor to protect against voltage peaks from your
  203.   ac outlet.
  204.  
  205.   As the manufacturers change the shapes of their batteries every few
  206.   months, you might have problems to find a new battery for your laptop
  207.   in a few years from now. Buy a spare battery now - before it's out of
  208.   stock.
  209.  
  210.   2.2.  Power saving - The obvious stuff
  211.  
  212.   There are some obvious things that you can do to reduce your system's
  213.   power consumption. Well, maybe not so obvious, since not very many
  214.   people follow these rules...
  215.  
  216.   ╖  Decrease or turn off your display's backlight when you don't need
  217.      it. By the way, tft displays use more power than dstn (so now you
  218.      have a fine excuse why you bought the cheaper laptop...).
  219.  
  220.      (David Bateman tells me that using a crt screen while on battery
  221.      and turning off the laptop display will extend battery time by
  222.      about 30%: ``Not that this is a very useful piece of knowledge
  223.      though, if you've got the crt plugged in then why not the laptop
  224.      too.'')
  225.  
  226.   ╖  How much processing power do you really need? I doubt that you will
  227.      be doing very much more than text editing when on the road (well,
  228.      at least I don't compile linux kernels then). While on battery,
  229.      reducing the cpu clock speed will decrease power consumption, too.
  230.      Quite a few laptops offer a cpu clock selector that will toggle
  231.      between normal and slow speed.
  232.  
  233.   ╖  Turn off the cpu cooler (if you have one). Many recent laptops
  234.      offer a bios option called ``cooling control''. If your system's
  235.      cpu is becoming too hot, this option allows you to have it cooled
  236.      by a tiny fan (setting ``performance'') or to have its cpu clock
  237.      slowed down (setting ``silence''). To increase your uptime while on
  238.      battery, use ``silence''.
  239.  
  240.   ╖  Avoid using external devices (printer, crt screen, zip drive,
  241.      portable camera etc.) with your computer while on battery. When
  242.      connected to a standard ink jet printer, my laptop's battery time
  243.      is reduced from up to 120 minutes down to 20 minutes.
  244.  
  245.   ╖  Avoid using any built in device unless necessairy: Diskette drive,
  246.      harddisk, cd-rom. Especially cd-rom access will dramatically
  247.      decrease your battery time.
  248.  
  249.   ╖  Pcmcia cards can also consume a lot of power, so don't leave your
  250.      modem or network adapter plugged in when it is not in use. But this
  251.      is different between the various pcmcia manufacturers, so check the
  252.      product specs before you buy (e. g. some cards never turn
  253.      themselves off even when not in use).
  254.  
  255.      (By the way, I recently read that pcmcia cards are the biggest
  256.      problem for windows ce palmtops - they drain so much power that the
  257.      tiny machines' little batteries have to be replaced within
  258.      minutes...)
  259.  
  260.   ╖  Use simple software. A full blown multimedia application will
  261.      create a lot more system load and harddisk / cd-rom activity than a
  262.      small simple word processor.
  263.  
  264.   ╖  Grant Taylor has a tip for those of us who want to upgrade their
  265.      system: ``Newer versions of some upgradable components consume less
  266.      power. For example, IBM's Travelstar 2.5 inch 1.6 gigabyte ide
  267.      harddisk drive consumes 20 percent less than the 500 megabyte
  268.      toshiba harddisk my laptop came with.''
  269.  
  270.   ╖  If you are yet about to buy a laptop - don't buy a laptop with a
  271.      2nd level cache if battery uptime is important. A computer with 2nd
  272.      level cache is about 10% to 20% faster and it will be a lot better
  273.      with multimedia applications and number crunching, but it consumes
  274.      a lot of power. Bjoern Kriews tells me that he has two almost
  275.      identical laptops and the one without cache ram runs 4h30 compared
  276.      to 2h30 with cache.
  277.  
  278.      If you already have 2nd level cache installed, turning it off will
  279.      probably not help you very much.  Give it a try and write me about
  280.      your experience.
  281.  
  282.   ╖  Another tip for those still buying a laptop - don't buy the latest,
  283.      fastest cpu type. Usually, the older generations are optimized by
  284.      the manufacturer after some time without notice. The ``new''
  285.      versions of old cpu types often create less heat and consume less
  286.      power than the product's premiere version.
  287.  
  288.      There are also frankenstein laptops available that use cpus not
  289.      optimized for portable systems. As I wrote this in May 97, the
  290.      newest generation pentium-200 laptops ran about 20 minutes on
  291.      battery and became so hot that they burnt your lap. When writing
  292.      the second revision in Oct 97, pentium-233 laptops run two hours or
  293.      longer without ac power. Go figure.
  294.  
  295.   Well, you get the idea. Most of these are restrictions that will
  296.   probably stop you from doing any serious work with your Linux system.
  297.   (The best way to save power while on battery is... not to do anything
  298.   at all. That increases my laptop's battery uptime by almost 100
  299.   percent.)
  300.  
  301.   So let's go ahead to some other, more useful measures that will save
  302.   power without disturbing your work.
  303.   3.  Advanced Power Management
  304.  
  305.   Portable systems in general, but even many desktop computers come
  306.   equipped with support for apm, the ``advanced power management''
  307.   scheme. This section describes how to activate apm support in your
  308.   Linux kernel. People who are experienced with Linux may find this
  309.   section rather boring and want to skip to the next.
  310.  
  311.   3.1.  What APM can do for you
  312.  
  313.   I won't describe it in detail here, check the Linux APM drivers page
  314.   at http://www.cs.utexas.edu/users/kharker/linux-laptop/apm.html for
  315.   more information. All that you need to know is that with the help of
  316.   apm, the cpu can tell the bios when there's nothing really exciting
  317.   going on so that the bios can take care of some power saving by itself
  318.   - e. g. reducing the cpu clock, turning off the harddisk, turning off
  319.   the display's backlight etc.
  320.  
  321.   Apm is also responsible for the ``system suspend'' (or ``sleep'') mode
  322.   and for the ``suspend to disk'' (or ``hiberntation'') mode. And yet
  323.   another cool, though not very important feature is that with the help
  324.   of apm, shutdown -h will not just halt your system, but also turn it
  325.   off.
  326.  
  327.   (By the way, most Linux systems put a shutdown -r in their
  328.   /etc/inittab and map it to pressing control-alt-delete. I prefer
  329.   having shutdown -h there, so when pressing the famous key combination,
  330.   my laptop simply turns itself off.)
  331.  
  332.   Not all manufacturers implement a correct apm bios, so some laptops
  333.   have trouble with the Linux apm drivers (if your machine has trouble
  334.   with apm, it will most likely either lock up at Linux' boot up or
  335.   after returning from suspend). If you are not sure, check the Linux
  336.   laptop page for your specific model.
  337.  
  338.   3.2.  How to activate APM support in Linux
  339.  
  340.   It's easy - just recompile the Linux kernel. Check the Kernel-HOWTO if
  341.   you don't know how to do that.
  342.  
  343.   When the configuration script reaches the ``character devices''
  344.   section, the default setting for full apm bios support in kernel
  345.   version 2.0.30 or higher is:
  346.  
  347.        Advanced Power Management BIOS support: Yes
  348.        Ignore USER SUSPEND: No
  349.        Enable PM at boot time: Yes
  350.        Make CPU Idle calls when idle: Yes
  351.        Enable console blanking using APM: Yes
  352.        Power off on shutdown: Yes
  353.  
  354.   Please read the configuration script's help texts. They explain in
  355.   detail what each option does, so I won't repeat them here.
  356.  
  357.   If your system does not fully support the apm bios standard, some of
  358.   those options might crash your system. Test all apm features with the
  359.   new kernel to make sure that everything works as it should.
  360.  
  361.   (A sidenote about console blanking: David Bateman tells me that you
  362.   should not enable it because it can cause problems with the current
  363.   version of XFree 3.2: ``The symptoms are that the screen will be blank
  364.   when X starts, and it can be fixed usually by just hitting a key. It's
  365.   a small but annoying problem. The next relase of XFree, will have
  366.   pretty good DPMS support for a lot of laptop chipset, which should
  367.   include code to turn off the LCD. Check out the manpage for xset in
  368.   XFree 3.2A.'' David also notes that the lifetime of your display's
  369.   backlight is determined by the number of times it's switched on and
  370.   off: ``So its a compromise, lifetime of the battery versus lifetime of
  371.   the backlight.'')
  372.  
  373.   (Update: With XFree 3.3, this problem still remained on my laptop. I
  374.   am told that this will be fixed in a future kernel version.)
  375.  
  376.   3.3.  APM support and the PCMCIA drivers
  377.  
  378.   After recompiling the kernel, don't forget to recompile the linux
  379.   pcmcia drivers as well.
  380.  
  381.   The precompiled pcmcia drivers that come with most linux distribution
  382.   have apm support disabled, so that the bios can't instruct your card
  383.   adapters to turn off.
  384.  
  385.   Also, you must recompile the drivers if you upgrade to a new kernel
  386.   version and your old kernel was compiled with module version
  387.   information turned on (this option is found in the ``loadable module
  388.   support'' section of the kernel configuration).
  389.  
  390.   Read the PCMCIA-HOWTO for detailed instructions on how to compile the
  391.   drivers or go to the Linux PCMCIA drivers homepage at
  392.   http://hyper.stanford.edu/HyperNews/get/pcmcia/home.html.
  393.  
  394.   3.4.  The apmd package
  395.  
  396.   Now that you have APM support installed, go and get the apmd package
  397.   from the Linux APM drivers page. You don't really need it, but it is a
  398.   very useful collection of programs. The apmd daemon logs your
  399.   battery's behaviour and it will send out a warning if you are on low
  400.   power. The apm command will suspend your system with a shell command
  401.   and xapm shows the current state of your battery.
  402.  
  403.   (BTW, if you have problems with pcmcia cards after returning from
  404.   suspend, you can check out an alternative apmd package at
  405.   http://www.cut.de/bkr/linux/apmd/apmd.html. It unloads the pcmcia
  406.   driver module before going to suspend and reloads the module on
  407.   resume.)
  408.  
  409.   Grant Taylor has been playing a little with the apmd package and came
  410.   up with helpful tips.
  411.  
  412.   He found that his laptop's harddisk forgets its hdparm -S standby
  413.   period when returning from suspend: ``I modified apmd to reset this
  414.   setting on each resume. This may be system-specific; but it's an
  415.   important thing to do...''
  416.  
  417.   (Note: On my own laptop, the bios takes care of the harddisk standby
  418.   period and resets the value on resuming. So I could not test if this
  419.   little problem is system-specific. If it happens to you as well, send
  420.   me a message.)
  421.  
  422.   Grant also had a nice trick for screen blanking with ``the XFree86
  423.   package'' and the help of the apmd package, you'll find it there.
  424.  
  425.   3.5.  And if my laptop does not support APM?
  426.  
  427.   If your computer's bios does not offer any power saving settings (even
  428.   the old ones without apm should at least allow to set harddisk and
  429.   display standby), you can use hdparm -S to define your harddisk's
  430.   standby period. This will already help a lot, since harddisk activity
  431.   consumes a lot of power. Your system should have hdparm installed, so
  432.   read man hdparm for the command syntax.
  433.  
  434.   4.  Changing some general system settings
  435.  
  436.   After I got Linux up and running on my laptop, I found it accessing
  437.   the harddisk every few seconds, even when there was no user logged in
  438.   to the system. The harddisk could never enter its power saving mode.
  439.   Reducing harddisk activity can greatly increase the battery runtime,
  440.   so this is why I collected the following recipes.
  441.  
  442.   I tested all this with RedHat 4.1, the locations of some configuration
  443.   settings may be different for your distribution. (If so, please let me
  444.   know.)
  445.  
  446.   4.1.  The crond daemon and atrun
  447.  
  448.   Check your /etc/crontab file if it starts a process every minute. You
  449.   will often find atrun there.
  450.  
  451.   With the at command, you can spool commands that must be invoked some
  452.   time in the future. Some Linux systems use a dedicated atd daemon to
  453.   take care of this, others (e. g. RedHat) let the crond daemon run
  454.   atrun once every minute.
  455.  
  456.   This is not really necessairy on most systems, since at commands
  457.   rarely depend upon being invoked on exact time. So if you find a line
  458.   like this in your /etc/crontab:
  459.  
  460.        # Run any at jobs every minute
  461.        * * * * * root [ -x /usr/sbin/atrun ] && /usr/sbin/atrun
  462.  
  463.   Then you can safely change this to:
  464.  
  465.        # Run any at jobs every hour
  466.        00 * * * * root [ -x /usr/sbin/atrun ] && /usr/sbin/atrun
  467.  
  468.   Read man 5 crontab for details. Some folks can even work fine without
  469.   the crond daemon, so if you know what you are doing, you might want to
  470.   consider disabling it completely.
  471.  
  472.   4.2.  The update / bdflush daemon
  473.  
  474.   Linux deals with a lot of open file buffers at any given moment, so
  475.   the system must make sure that file changes are saved to the harddisk
  476.   as soon possible. Otherwise, those changes will be lost after a system
  477.   crash.
  478.  
  479.   The update / bdflush daemon takes care of this. (These are two names
  480.   for the same program, so you can use either name to start the daemon).
  481.   The default settings will make this daemon call flush every 5 seconds
  482.   and sync every 30 seconds.
  483.  
  484.   With my Fujitsu disk this caused non-stop access. (It seems that this
  485.   harddisk flushes its ram cache even when nothing has changed. But this
  486.   depends on your harddisk's firmware: Other people told me that their
  487.   harddisk does enter its power saving mode even without the following
  488.   modification.)
  489.  
  490.   Since Linux does not crash very often anymore, I have changed both
  491.   values to 3600 seconds (= one hour). This caused no problems at all
  492.   and the constant disk access has stopped. (But if my system crashes
  493.   now, there will be more broken files, of course.)
  494.  
  495.   RedHat 4.1: In /etc/inittab, change the update call to:
  496.  
  497.        ud::once:/sbin/update -s 3600 -f 3600
  498.  
  499.   Suse 4.4.1: update is called in /sbin/init.d/boot.
  500.  
  501.   Slackware: update is called in /etc/rc.d/rc.S.
  502.  
  503.   See man update for details.
  504.  
  505.   4.3.  The syslogd daemon
  506.  
  507.   The syslogd daemon is responsible for the various Linux system log
  508.   files that are found in the /var/log/ directory. By default syslogd
  509.   will sync the log file each time after logging a system message.
  510.  
  511.   You can turn that off by preceding the filename with a dash in
  512.   /etc/syslog.conf. Here's an example as found in my system's
  513.   syslog.conf:
  514.  
  515.        # Log anything (except mail) of level info or higher.
  516.        # Don't log private authentication messages!
  517.        *.info;mail.none;authpriv.none                  -/var/log/messages
  518.  
  519.   This again means that if the system crashes, the message that reported
  520.   the problem may not have been stored to disk. Dilemma...
  521.  
  522.   4.4.  The init command
  523.  
  524.   During the bootup, the initial processes and daemons will be started
  525.   using the init command. This command (yet again) calls sync before
  526.   each process it creates.
  527.  
  528.   You can change this by removing the sync() call in the source code and
  529.   recompiling the command.
  530.  
  531.   To avoid problems with lost file buffers, you should add a call to
  532.   sync in your system's /etc/rc.d/init.d/halt script, right before the
  533.   script unmounts the file systems.
  534.  
  535.   4.5.  The swap partition
  536.  
  537.   The Linux swap partition is used to increase the physical ram space
  538.   with virtual memory. This again is a possible reason for harddisk
  539.   access. If your laptop already has a lot of ram or if the applications
  540.   that you use are quite simple (think of vi), you might want to
  541.   consider turning it off.
  542.  
  543.   This of course depends on what you plan to do. 4 to 8 megs are not
  544.   enough, you must use a swap partition then. With 8 to 16 megs, text
  545.   console applications will work fine and if you can avoid using a lot
  546.   of multitasking features, you can safely disable swap. The X-Windows
  547.   enviroment requires a lot of ram and you should not use it without a
  548.   swap partition unless you really have a lot more than 16 megs.
  549.  
  550.   (Sidenote: My laptop with 16 megs and disabled swap partition can run
  551.   an emacs session, four bash shells and compile a kernel without
  552.   running out of memory. That's enough for me.)
  553.  
  554.   If you already have installed a swap partition, you can disable it by
  555.   preceding the swapon command that is called in /etc/rc.d/rc.sysinit
  556.   with a hash mark. If you don't want to make it a permanent move, let
  557.   the system ask during boot if you want to use the swap partition. In
  558.   /etc/rc.d/rc.sysinit (RedHat 4.1) or /sbin/init.d/boot (Suse 4.4.1):
  559.  
  560.        echo "Should the system use swap?"
  561.        echo "  0: No."
  562.        echo "  1: Yes."
  563.        /bin/echo "Your choice: \c"
  564.        read SWAPCHOICE
  565.  
  566.        case "$SWAPCHOICE" in
  567.            0)
  568.                # Do nothing.
  569.                echo "(Swap partitions disabled)"
  570.                ;;
  571.            *)
  572.                # Start up swapping.
  573.                echo "Activating swap partitions"
  574.                swapon -a
  575.        esac
  576.  
  577.   Then you can use the swap partition while on ac power and drop it
  578.   while on battery.
  579.  
  580.   4.6.  The apache httpd webserver daemon
  581.  
  582.   I am using my laptop to develop and test cgi scipts for websites, that
  583.   is why I am running a local webserver on it. The standard
  584.   configuration is a bit too much if all you want to do is just test a
  585.   script or check a page from time to time.
  586.  
  587.   In httpd.conf, just change the values of MinSpareServers and
  588.   StartServers to 1. This will be enough for a local test site.
  589.  
  590.   If you wish to turn off the webserver's logging, you must recompile
  591.   the httpd daemon. Read the documentation for details.
  592.  
  593.   Grant Taylor recompiled apache's logging and found that this ``didn't
  594.   make it stop churning the disk. So I used another, IMHO better,
  595.   solution: I configured apache to run from inetd instead of
  596.   standalone.'' Read man inetd for details.
  597.  
  598.   4.7.  The XFree86 package
  599.  
  600.   Configuring XFree86 for laptops is a story of its own. And yet again,
  601.   I have to refer you to the Linux Laptop page where you will find a lot
  602.   of help on this.
  603.  
  604.   X's console blanking only turns the screen black, but does not turn it
  605.   off. As mentioned in the ``sidenote about console blanking'', you can
  606.   use xset's dpms option to change this.  However, this feature depends
  607.   on your laptop's graphics chipset and bios.
  608.  
  609.   Grant Taylor uses the following setup to send his laptop to sleep with
  610.   the help of apmd and the screensaver:
  611.  
  612.        # Run xscreensaver with APM program
  613.        xscreensaver -timeout 5 \
  614.                     -xrm xscreensaver.programs:apm_standby \
  615.                     -xrm xscreensaver.colorPrograms:apm_standby &
  616.  
  617.   Where ``apm_standby is a suid perl script that allows only certain
  618.   people to run apm -S.''
  619.  
  620.   4.8.  The emacs editor
  621.  
  622.   Ok, emacs is not an editor, but a way of life. Here's a tip from
  623.   Florent Chabaud: ``If you use emacs, perhaps you have noticed that the
  624.   editor makes some automatic saves.  This is of course useful and
  625.   should not be disabled, but the default parameters can be adjusted to
  626.   a laptop use.
  627.  
  628.   I have put in the file /usr/share/emacs/site-lisp/site-start.el the
  629.   two following lines:
  630.  
  631.        (setq auto-save-interval 2500)
  632.        (setq auto-save-timeout nil)
  633.  
  634.   This disables auto-saving based on time, and makes the auto-saving be
  635.   done every 2500 keyboard actions. Of course if you are typing a text
  636.   this last parameter should be reduced, but for programming it is
  637.   sufficient. Since every action (up, down, left, backspace, paste,
  638.   etc...) is counted, 2500 actions are reached very rapidly.''
  639.  
  640.   4.9.  How to find more ways to optimize
  641.  
  642.   If your Linux system still seems to access the harddisk too often, you
  643.   can find out what is going on inside by using the ps ax command. This
  644.   will show all running processes and their full name, sometimes it also
  645.   reveals the command line arguments of each process.
  646.  
  647.   Now read the man page of each process to find out what it does and how
  648.   to change its behaviour. With this method, you will most likely find
  649.   the process that is responsible. You may also find strace helpful.
  650.  
  651.   Please send me an email if you found something new.
  652.  
  653.   5.  Appendix
  654.  
  655.   5.1.  A message to Linux distributors
  656.  
  657.   If you happen to be a Linux distributor, thank you for reading all
  658.   this. Laptops are becoming more and more popular, but still most Linux
  659.   distributions are not very well prepared for portable computing.
  660.   Please make this document obsolete and change this for your
  661.   distribution.
  662.  
  663.   ╖  The installation routine should include a configuration, optimized
  664.      for laptops. The ``mimimal install'' is often not lean enough.
  665.      There are a lot of things that a laptop user does not need on the
  666.      road. Just a few examples. There is no need for three different
  667.      versions of vi (as found in Suse Linux). Most portable systems do
  668.      not need printing support (they will never be connected to a
  669.      printer, printing is usually done with the desktop system at home).
  670.      Quite a few laptops do not need any network support at all.
  671.  
  672.   ╖  Don't forget to describe laptop-specific installation problems, e.
  673.      g. how to install your distribution without a cd-rom drive or how
  674.      to setup the plip network driver.
  675.  
  676.   ╖  Add better power management and seamless pcmcia support to your
  677.      distribution. Add a precompiled kernel and an alternative set of
  678.      pcmcia drivers with apm support that the user can install on
  679.      demand. Include a precompiled apmd package with your distribution.
  680.  
  681.   ╖  Add support for dynamically switching network configurations. Most
  682.      Linux laptops travel between locations with different network
  683.      settings (e. g. the network at home, the network at the office and
  684.      the network at the university) and have to change the network id
  685.      very often. Changing a Linux system's network id is a pain with
  686.      most distributions.
  687.  
  688.   Please mail me if your distribution is optimized for portable
  689.   computing and what kind of features you added for that. Future
  690.   versions of this HOWTO will include a section where you can advertise
  691.   your distribution's laptop features.
  692.  
  693.   5.2.  Credits
  694.  
  695.   ╖  The information about battery technology is mostly based on the
  696.      article ``Stromkonserve'' by Michael Reiter, published in ``c't
  697.      Magazin fuer Computertechnik'' (Heise Verlag Hannover, Germany),
  698.      edition 10/96, page 204. Used by permission. Visit their website at
  699.      http://www.heise.de/.
  700.  
  701.   ╖  The following people contributed to this document:
  702.  
  703.        Frithjof Anders <anders@goethe.ucdavis.edu>
  704.        David Bateman <dbateman@ee.uts.edu.au>
  705.        Florent Chabaud <chabaud@celar.fr>
  706.        Markus Gutschke <gutschk@uni-muenster.de>
  707.        Kenneth E. Harker <kharker@cs.utexas.edu>
  708.        Bjoern Kriews <bkr@rrz.uni-hamburg.de>
  709.        R. Manmatha <manmatha@bendigo.cs.umass.edu>
  710.        Juergen Rink <jr@ct.heise.de>
  711.        Grant Taylor <gtaylor@picante.com>
  712.        James Youngman <JYoungman@vggas.com>
  713.  
  714.   5.3.  About this document
  715.  
  716.   This text mentions batteries 53 times.
  717.  
  718.   The current version of this and many other HOWTOs, most of them a lot
  719.   more useful than this one, can be found at the main Linux
  720.   documentation site http://sunsite.unc.edu/mdw/linux.html or at one of
  721.   its many mirror sites.
  722.  
  723.   Most of this text was written during my trips between Hamburg and
  724.   Hannover on German rail. (The new ice-2 coaches have power outlets for
  725.   laptops, yeah!).
  726.  
  727.   And now hum along with me: ``...on the road again...''
  728.  
  729.